package com.moonshine.parser.models;

import java.util.ArrayList;
import java.util.List;

public class MethodSignature extends AS3Signature {

	public String returnType = "void";
	public List<VariableSignature> paramaters = new ArrayList<VariableSignature>();

	public ClassSignature classSig;

	public String toString(Boolean pretty, Boolean omitIndices) {
		final StringBuilder sb = new StringBuilder();
		sb.append(pretty ? "function " : "f ");
		sb.append(super.toString(pretty, omitIndices));

		sb.append(pretty ? (name + "(") : " " + name);
		if (!pretty)
			sb.append(" " + returnType + " ");
		if (paramaters.size() > 0) {
			final int count = paramaters.size();
			for (int i = 0; i < count; i++) {
				sb.append(paramaters.get(i).toString(pretty));
				if (i + 1 < count) {
					sb.append(",");
				}
			}

		}
		sb.append(pretty ? ("):" + returnType) : " ");
		if (!omitIndices) {
			if (pretty)
				sb.append(" [");
			AS3Signature.appendIndices(sb, this, pretty);
			if (pretty)
				sb.append("]");
		}
		return sb.toString();
	}
}
